#ifndef WINDOWMANAGER_H
#define WINDOWMANAGER_H

#include "mdrawingboard.h"
#ifdef GUI_APPLICATION

#include "mobject.h"
#include "guistructure.h"

class MApplication;
class MEventLoop;
class MWidget;

class MWindowManager : public MObject
{
	private:
		MWindowManager();
		virtual ~MWindowManager();

	private:
		static int initialize();
		static const MWindowManager *const uniqueObject();

	private:
		const MWidget *currentFocus();

	private:
		void newWindow(MWidget &widget) const;
		void closeWindow(MWidget &widget) const;

	private:
		void setWindowTitle(MWidget &widget) const;
		void setBackgroundColor(MWidget &widget) const;
		void resize(MWidget &widget) const;
		void move(MWidget &widget) const;
		void putOnTop(MWidget &widget) const;
		void putOnBottom(MWidget &widget) const;

	private:
		void update(MWidget &widget) const;
		void setVisible(MWidget &widget, bool visible = true) const;
		void setState(MWidget &widget, Jxq::WindowState state) const;

	private slots:
		void systemColorChange();

	private:
		bool isInvalid() const;
		void updateEvent() const;
		virtual void timerEvent(MTimerEvent *event);

	private:
		M_DISABLE_COPY(MWindowManager)
		friend class MApplication;
		friend class MEventLoop;
		friend class MWidget;
};


#endif //GUI_APPLICATION

#endif //WINDOWMANAGER_H
